package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)

func main()  {
	//创建路由
   r :=  gin.Default()
   //绑定路由规则，执行函数
   //gin.context,封装requset和response
   r.GET("/form", func(c *gin.Context) {
   	//    name := c.Param("name")
   	//    action:= c.Param("action")
   	//    action =strings.Trim(action,"/")
   	//    c.DefaultQuery("name","枯藤")
   	//   // c.String(http.StatusOK,name+" is "+action)
	   ////c.String(http.StatusOK,"hello World!")
	   //c.String(http.StatusOK, fmt.Sprintf("hello %s", name))
		   types := c.DefaultPostForm("type", "post")
		   username := c.PostForm("username")
		   password := c.PostForm("userpassword")
		   // c.String(http.StatusOK, fmt.Sprintf("username:%s,password:%s,type:%s", username, password, types))
		   c.String(http.StatusOK, fmt.Sprintf("username:%s,password:%s,type:%s", username, password, types))

   })
	// 3.监听端口，默认在8080
	// Run("里面不指定端口号默认为8080")
	r.Run(":8100")
}

